package com.ambulance.project.biz.controller.bigweb;


import com.ambulance.framework.security.service.SysLoginService;
import com.ambulance.framework.web.domain.AjaxResult;
import com.ambulance.framework.web.domain.AjaxResultData;
import com.ambulance.project.biz.enums.Source;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 人员信息 前端控制器
 * </p>
 *
 * @author zr
 * @since 2020-04-21
 */
@Api(tags = "可视化-登陆")
@RestController
@RequestMapping(value = "/web/v1/user", method = RequestMethod.POST)
public class WebUserController {

    @Autowired
    private SysLoginService sysLoginService;


    /**
     * 大屏登陆和管理平台登陆都是医院主体登陆
     * 医院登陆-登陆
     *
     * @param username
     * @param password
     * @return
     */
    @ApiOperation(value = "登陆", notes = "登陆", produces = "application/json")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "username", value = "账户", dataType = "string"),
            @ApiImplicitParam(name = "password", value = "密码", dataType = "string"),

    })
    @ApiResponses({
            @ApiResponse(code = 200, response = AjaxResultData.class, message = "响应")
    })
    @RequestMapping(value = "/login")
    public Object login(@RequestParam(value = "username") String username,
                        @RequestParam(value = "password") String password) {

        String token = sysLoginService.loginNoCaptcha(username, password, Source.BWE);
        return AjaxResult.success(token);
    }

}
